﻿@using LunwenYun.Infrastructure.Entities.Entity;
@using LunwenYun.Infrastructure.Entities.Enum;
@{
    Layout = "~/Views/Shared/_o_Main.cshtml";
}
@section head{
<script type="text/javascript" src="/Scripts/plug.js"></script>
}
<div class="mini-layout graybg">
    <form id="mlistform" action="/o/mlist" method="post">
    <input id="hidind" type="hidden" name="ind" value="@ViewBag.IndType" />
    <input id="hidapt" type="hidden" name="apt" value="@ViewBag.Aptitude" />
    <input id="hidlang" type="hidden" name="lang" value="@ViewBag.Language" />
    <div class="row">
        <div class="span1">
            <span class="btn btn-info prebtn">行业</span>
        </div>
        <div class="span10">
            <span class="float-left">
                <ul id="indtypenav" class="nav nav-pills">
                    <li>
                        <a onclick="triggerIndType('-1',this)" href="javascript:;">所有</a>
                    </li>
                    <script type="text/javascript">
                        for (var i = 0, len = data.IndType.length; i < len; i++) {
                            document.writeln('<li><a href="javascript:;" onclick="triggerIndType(' + data.IndType[i].value + ',this)">' + data.IndType[i].name + '</a></li>');
                        }
                    </script>
                </ul>
            </span>
        </div>
    </div>
    <div class="row">
        <div class="span1">
            <span class="btn btn-info prebtn">类型</span>
        </div>
        <div class="span10">
            <span class="float-left">
                <ul id="aptnav" class="nav nav-pills">
                    <li><a href="javascript:;" onclick="triggerApt(-1,this)">所有</a></li>
                    <script type="text/javascript">
                        for (var i = 0, len = data.Aptitude.length; i < len; i++) {
                            document.writeln('<li><a href="javascript:;" onclick="triggerApt(' + data.Aptitude[i].value + ',this)">' + data.Aptitude[i].name + '</a></li>');
                        }
                    </script>
                </ul>
            </span>
        </div>
    </div>
    <div class="row">
        <div class="span1">
            <span class="btn btn-info prebtn">语言</span>
        </div>
        <div class="span10">
            <span class="float-left">
                <ul id="aptlang" class="nav nav-pills">
                    <li><a href="javascript:;" onclick="triggerLanguage(-1,this)">所有</a></li>
                    <script type="text/javascript">
                        for (var i = 0, len = data.Language.length; i < len; i++) {
                            document.writeln('<li><a href="javascript:;" onclick="triggerLanguage(' + data.Language[i].value + ',this)">' + data.Language[i].name + '</a></li>');
                        }
                    </script>
                </ul>
            </span>
        </div>
    </div>
    </form>
</div>
<!-- Manuscripts -->
@{
    ItemListBox<Article> data = (ItemListBox<Article>)ViewBag.Data;
    }
<table class="table table-hover">
    <tbody>
    @if (data != null && data.Data != null && data.Data.Any())
    {
        foreach (var item in data.Data)
        { 
            <tr>
            <td>
                <div class="pull-left">
                    <div class="doc">
                        <img src="/content/img/doc.png" /></div>
                </div>
                <div class="pull-left">
                    <h5>
                        <a>@item.Title</a></h5>
                    <p>
                        <strong>分类：</strong>@item.IndType.Mapping() -> @item.SubIndType.Mapping()<br />
                        
                        <strong>方向：</strong>
                        @if(!String.IsNullOrEmpty(item.Aptitude))
                        {
                            string aptString = string.Empty;
                            List<string> apt = item.Aptitude.Split(';').Where(c => !String.IsNullOrEmpty(c)).ToList();
                            foreach(var aptitem in apt)
                            {
                                try{
                                    int iapt = Int32.Parse(aptitem);
                                    aptString += ((Aptitude)iapt).Mapping() + "、";
                                }
                                catch{}
                            }
                            aptString = aptString.EndsWith(";") ?
                                aptString.Remove(aptString.Length) : aptString;
                            <span>@aptString @item.Language.Mapping()</span>
                        }
                        <br />
                        <strong>预算：</strong>@item.PriceRange</p>
                </div>
            </td>
            <td style="width: 20%; text-align: right" class="center">
                @if(item.Status == ArticleStatus.Complete)
                {
                    <input type="button" disabled="disabled" class="btn btn-success btn-mini"
                        value="已完成" />
                }
                else if(item.ExpireTime < DateTime.Now)
                {
                    <input type="button" disabled="disabled" class="btn btn-inverse btn-mini"
                        value="已结束" />
                }
                else
                {
                    <a class="btn btn-primary btn-mini">进行中</a>
                }
            </td>
        </tr>
        }
    }
    </tbody>
</table>
@Html.Raw(data.PageItemSegment)
@section tail{
<script type="text/javascript">
    $(function () {
        $('#likmlist').addClass('active');
        var indtype= @ViewBag.IndType;
        indtype = indtype == -1?0:parseInt(indtype,10)+1;
        $('#indtypenav').children('li').eq(indtype).addClass('active');

        var aptitude = @ViewBag.Aptitude;
        aptitude = aptitude == -1?0:parseInt(aptitude,10);
        aptitude = aptitude == 99?12:aptitude;
        $('#aptnav').children('li').eq(aptitude).addClass('active');

        var language = @ViewBag.Language;
        language = language == -1?0:language;
        language = language == 9?3:language;
        $('#aptlang').children('li').eq(language).addClass('active');        
    });
    function triggerIndType(indType, sender) {
        $(sender).parent().siblings('li').each(function () {
            $(this).removeClass('active');
        });
        $(sender).parent().addClass('active');
        $('#hidind').val(indType);
        $('#mlistform').submit();
    }
    function triggerApt(apt, sender) {
        $(sender).parent().siblings('li').each(function () {
            $(this).removeClass('active');
        });
        $(sender).parent().addClass('active');
        $('#hidapt').val(apt);
        $('#mlistform').submit();
    }
    function triggerLanguage(lang, sender) {
        $(sender).parent().siblings('li').each(function () {
            $(this).removeClass('active');
        });
        $(sender).parent().addClass('active');
        $('#hidlang').val(lang);
        $('#mlistform').submit();
    }
</script>
}
